package com.itheima.controller;

import com.itheima.pojo.Result;
import com.itheima.config.OssTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
public class FileController {
    @Autowired
    private OssTemplate ossTemplate;
    @PostMapping("upload")
    public Result uploadFile(MultipartFile image) throws IOException {     // 文件上传格式
        String upload = ossTemplate.upload(image.getOriginalFilename(), image.getInputStream());
        return Result.success(upload);
    }
}
